﻿Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Collections.Specialized
Imports Lourdes.BackEnd
Imports Lourdes.BackEnd.BC
Public Class frmDashboard
  Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    'test()
    Threading.Thread.CurrentThread.Sleep(1000)
    If Not IsPostBack Then
      VtasConf()
      VendedoresConf()
      MercaConf()
      ClientesConf()
    End If
  End Sub
  Private Sub test()

    'Dim dt As DataTable = (New ReportSources).getVendedores(Now.AddDays(-50), Now.AddDays(1))
  End Sub


#Region "VENTAS"
  Private Sub VtasConf()
    With ucVentas
      Select Case cmbVentas.SelectedValue
        Case "dia"
          .DataSource = (New ReportSources).getVentasDia
          .Tooltips.FormatString = "Hora: <ITEM_LABEL> - Ventas: $<DATA_VALUE:00.##>"
          .TitleTop.Text = "Ventas del día"
        Case "semana"
          .DataSource = (New ReportSources).getVentasSemana
          .Tooltips.FormatString = "Día: <ITEM_LABEL> - Ventas: $<DATA_VALUE:00.##>"
          .TitleTop.Text = "Ventas de la semana"
        Case "mes"
          .DataSource = (New ReportSources).getVentasMes
          .Tooltips.FormatString = "Día: <ITEM_LABEL> - Ventas: $<DATA_VALUE:00.##>"
          .TitleTop.Text = "Ventas del mes"
      End Select
      .DataBind()
    End With
  End Sub

  Private Sub cmbVentas_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles cmbVentas.SelectedIndexChanged
    VtasConf()
  End Sub

#End Region

#Region "VENDEDORES"
  Private Sub VendedoresConf()
    With ucVendedores
      Select Case cmbVendedores.SelectedValue
        Case "dia"
          .DataSource = (New ReportSources).getVendedoresDia
          .TitleTop.Text = "Ventas por vendedor del día"
        Case "semana"
          .DataSource = (New ReportSources).getVendedoresSemana
          .TitleTop.Text = "Ventas por vendedor de la semana"
        Case "mes"
          .DataSource = (New ReportSources).getVendedoresMes
          .TitleTop.Text = "Ventas por vendedor del mes"
      End Select
      .Tooltips.FormatString = "Vendedor: <ITEM_LABEL> - Ventas: $<DATA_VALUE:00.##>"
      .PieChart.Labels.FormatString = "<ITEM_LABEL>: $<DATA_VALUE:#> (<PERCENT_VALUE:#>%)"
      .DataBind()
    End With
  End Sub

  Private Sub cmbVendedores_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles cmbVendedores.SelectedIndexChanged
    VendedoresConf()
  End Sub
#End Region

#Region "MERCADERIAS MAS VENDIDAS"
  Private Sub MercaConf()
    With ucMerca
      Select Case cmbMerca.SelectedValue
        Case "dia"
          .DataSource = (New ReportSources).getMercaDia
          .TitleTop.Text = "Ventas por vendedor del día"
        Case "semana"
          .DataSource = (New ReportSources).getMercaSemana
          .TitleTop.Text = "Ventas por vendedor de la semana"
        Case "mes"
          .DataSource = (New ReportSources).getMercaMes
          .TitleTop.Text = "Ventas por vendedor del mes"
      End Select
      .Tooltips.FormatString = "Producto: <ITEM_LABEL> - Ventas: $<DATA_VALUE:00.##>"
      .PieChart.Labels.FormatString = "<ITEM_LABEL>: $<DATA_VALUE:#> (<PERCENT_VALUE:#>%)"
      .DataBind()
    End With
  End Sub
  Private Sub cmbMerca_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles cmbMerca.SelectedIndexChanged
    MercaConf()
  End Sub
#End Region


#Region "CLIENTES MAS COMPRADORES"
  Private Sub ClientesConf()
    With ucClientes
      Select Case cmbClientes.SelectedValue
        Case "dia"
          .DataSource = (New ReportSources).getClientesDia
          .TitleTop.Text = "Ventas por vendedor del día"
        Case "semana"
          .DataSource = (New ReportSources).getClientesSemana
          .TitleTop.Text = "Ventas por vendedor de la semana"
        Case "mes"
          .DataSource = (New ReportSources).getClientesMes
          .TitleTop.Text = "Ventas por vendedor del mes"
      End Select
      .Tooltips.FormatString = "Cliente: <ITEM_LABEL> - Ventas: $<DATA_VALUE:00.##>"
      .PieChart.Labels.FormatString = "<ITEM_LABEL>: $<DATA_VALUE:#> (<PERCENT_VALUE:#>%)"
      .DataBind()
    End With
  End Sub
  Private Sub cmbClientes_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles cmbClientes.SelectedIndexChanged
    ClientesConf()
  End Sub
#End Region

End Class